import gtk
import gtk.glade
from Doctor import *

class AddDoctorWindow:
	def __init__(self):
		gladefile="setup_pickup.glade"
		windowname="AddDoctorWindow"
		self.wTree=gtk.glade.XML (gladefile,windowname)
		dic = { "onAddClicked" : self.onAddClicked,
			"onCancelClicked" : self.onCancelClicked }
		self.wTree.signal_autoconnect (dic)
		self.doctors = Doctor()
		
	def onAddClicked(self, widget):
		firstName = str(self.wTree.get_widget("FirstNameText").get_text())
		lastName = str(self.wTree.get_widget("LastNameText").get_text())
		if firstName and lastName:
			print "adding doctor", firstName, lastName
			self.doctors.add(firstName, lastName)
			window = self.wTree.get_widget("AddDoctorWindow")
			window.destroy()
		else: 
			print "Nothing Entered"
		
	def onCancelClicked(self, widget):
		window = self.wTree.get_widget("AddDoctorWindow")
		window.destroy()
	
	